

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
#include <signal.h>
#include <syslog.h>
#include <sys/ipc.h>
#include <sys/msg.h>


#include "iotv30_config.h"
#include "ota_manager.h"
#include "plcgw_cfg.h"
#include "plcgw_sys.h"
#include "sys_msg_process.h"

#define  ota_log_debug  logout

int push_sysmsg_data(int msg_type, const void *psrc, uint32_t len)
{
	if(len > MAX_MSG_SIZE-8) {
		printf("too long:%d\n", len);
		return -1;
	}
	sys_main_msg_t *sys_msg = (sys_main_msg_t*)malloc(sizeof(sys_main_msg_t));
	if(sys_msg) {
		sys_msg->msg_type = msg_type;
		sys_msg->dat_len = len;
		memcpy(sys_msg->msg_dat, psrc, len);

#if 0   //暂时屏蔽掉队列--dan
		int res = push_sysmsg_queue(sys_msg, sizeof(sys_main_msg_t));
		ota_log_debug("push sys msgId=%d, len=%d, res=%d\n", msg_type, len, res );

		free(sys_msg);		
		return res;
#else

//	    ota_burn_flash_pro(sys_msg);
		ota_log_debug("push sys msgId=%d, len=%d, res=%d\n", msg_type, len, len );

		free(sys_msg);	
		return len;
#endif

	}
	return -1;
}

